package com.example.springboot4;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.data.web.config.EnableSpringDataWebSupport;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j
@SpringBootApplication
@MapperScan("com.example.springboot4.**")
@EnableSpringDataWebSupport(pageSerializationMode = EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO)
public class SpringBoot4Application {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableEnvironment environment = SpringApplication.run(SpringBoot4Application.class, args).getEnvironment();
        log.info("""

                        ----------------------------------------------------------
                        \t\
                        Application '{}' is running! Access URLs:
                        \t\
                        Local: \t\thttp://localhost:{}{}
                        \t\
                        External: \thttp://{}:{}{}
                        \t\
                        Doc:     \thttp://{}:{}{}/doc.html
                        \t\
                        Swagger: \thttp://{}:{}{}/swagger-ui/index.html
                        ----------------------------------------------------------""",
                environment.getProperty("spring.application.name"),

                environment.getProperty("server.port"),
                environment.getProperty("server.servlet.context-path"),

                InetAddress.getLocalHost().getHostAddress(),
                environment.getProperty("server.port"),
                environment.getProperty("server.servlet.context-path"),

                InetAddress.getLocalHost().getHostAddress(),
                environment.getProperty("server.port"),
                environment.getProperty("server.servlet.context-path"),

                InetAddress.getLocalHost().getHostAddress(),
                environment.getProperty("server.port"),
                environment.getProperty("server.servlet.context-path"));
    }

}
